import { getEditor } from "./test.ts";
import { assertEquals } from "jsr:@std/assert";
Deno.test("selector test", async () => {
  const editor = getEditor();
  //第一次查询
  const data = editor.selectors.selectQd("qd");
  //第二次查询 会走缓存
  const data1 = editor.selectors.selectQd("qd");
  assertEquals(data, data1);
  //执行更新 start
  const tr = editor.tr;
  await tr.asyncTransaction((doc) => {
    doc.attrs.value += 1;
    tr.setNodeAttribute("1", { name: "我是测试", email: "alice@example.com" });
  });
  editor.dispatch(tr);
  //执行更新 end

  //第三次查询 没有缓存
  const data2 = editor.selectors.selectQd("qd");

  //第四次查询  走缓存
  const data3 = editor.selectors.selectQd("qd");
  assertEquals(data2, data3);
  editor.selectors.selectDw();
  
});
